package com.nbjtjc.safe.api.emg;

import com.nbjtjc.safe.annotation.SysLog;
import com.nbjtjc.safe.api.AbstractController;
import com.nbjtjc.safe.bean.Page;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.emg.EmgDuty;
import com.nbjtjc.safe.service.emg.EmgDutyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 应急值班
 */
@RestController
@CrossOrigin("*")
@RequestMapping("/duty")
public class EmgDutyController extends AbstractController<EmgDuty> {

    @Autowired
    private EmgDutyService emgDutyService;


    @RequestMapping(value = "/add",method = {RequestMethod.POST})
    @SysLog("添加应急的值班")
    public Result add(EmgDuty emgDuty){
        Result result=new Result();
        try {
            result=emgDutyService.add(emgDuty);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

    @Override
    @RequestMapping(value = "/delete",method = {RequestMethod.POST})
    @SysLog("删除应急的值班")
    public Result delete(int id) {
        Result result=new Result();
        try {
            result=emgDutyService.delete(id);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

    @Override
    @RequestMapping(value = "/find",method = {RequestMethod.POST,RequestMethod.GET})
    public Result find(EmgDuty emgDuty, Page page) {
        Result result=new Result();
        try {
            result=emgDutyService.find(emgDuty,page);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }
}
